package com.cyh;

import reactor.core.publisher.Mono;

public class MonoCreateTest01 {

    public static void main(String[] args) {
        Mono<Object> mono = Mono.create(sink -> {
            try {
                sink.success(fetchDataFromRemote());
            } catch (Exception e) {
                sink.error(e);
            }
        });
        System.out.println(mono);
        mono.subscribe(data -> System.out.println("Success: " + data), error -> System.err.println("Fail: " + error));
    }

    private static String fetchDataFromRemote() {
        return "Hello from Mono.create!";
    }
}
